package cn.sdormitory.controller.canteen;


import cn.sdormitory.canteen.service.FoodOrderService;
import cn.sdormitory.canteen.vo.CanteenDashBoradVO;
import cn.sdormitory.canteen.vo.FoodOrderVO;
import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.common.utils.ImageToTextAIUtils;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "food-dashboard=> 数据看板")
@RequestMapping("/food/dashboard")
public class CanteenDashboardController {

    @Autowired
    private FoodOrderService foodOrderService;

    @ApiOperation("getOrderGoodsTop10 => 获取订单商品的前十名")
    @GetMapping(value = "/getOrderGoodsTop10")
    public CommonResult<CanteenDashBoradVO> getOrderGoodsTop10(){
        CanteenDashBoradVO canteenDashBoradVO =  foodOrderService.getOrderGoodsTop10();
        return CommonResult.success(canteenDashBoradVO);
    }


    @ApiOperation("getWeekCheckPass => 获取一周商品验收情况")
    @GetMapping(value = "/getWeekCheckPass")
    public CommonResult<Map<String,Object>> getWeekCheckPass(){
        Map<String,Object> resultMap =  foodOrderService.getWeekCheckPass();
        return CommonResult.success(resultMap);
    }

    @ApiOperation("getWeekCheckPass => 获取供应商验商品收情况")
    @GetMapping(value = "/getSpplierCheckPass")
    public CommonResult<Map<String,Object>> getSpplierCheckPass(@RequestParam Integer limit){
        Map<String,Object> resultMap =  foodOrderService.getSpplierCheckPass(limit);
        return CommonResult.success(resultMap);
    }

    @ApiOperation("getCityWeather => 获取当前城市天气")
    @GetMapping(value = "/getCityWeather")
    public CommonResult<Map<String,Object>> getCityWeather(ServletRequest request){
        String weatherInfo = ImageToTextAIUtils.currentCityWeather();
        Map<String,Object> resultMap = JSON.parseObject(weatherInfo,Map.class);
        return CommonResult.success(resultMap);
    }

    @ApiOperation("getSampleCount => 获取样式数量")
    @GetMapping(value = "/getSampleCount")
    public CommonResult<Map<String,Object>> getSampleCount(ServletRequest request){
        String weatherInfo = ImageToTextAIUtils.currentCityWeather();
        Map<String,Object> resultMap = JSON.parseObject(weatherInfo,Map.class);
        return CommonResult.success(resultMap);
    }

    @ApiOperation("getSampleCount => 获取有效期/无效健康证")
    @GetMapping(value = "/getHealthCartInfo")
    public CommonResult<Map<String,Object>> getHealthCartInfo(ServletRequest request){
        String weatherInfo = ImageToTextAIUtils.currentCityWeather();
        Map<String,Object> resultMap = JSON.parseObject(weatherInfo,Map.class);
        return CommonResult.success(resultMap);
    }




}
